#ifndef TLU_H
#define TLU_H

#include <vector>
using namespace std;

#include "Timer.h"

class TLU
{
public:
	TLU( void );
	TLU( int MaxInputConnection, int MaxOutputConnection );

	struct InConnection
	{
		TLU* Link;
		Timer Time;
		int  Weight;
		char Data;
	};

	struct OutConnection
	{
		TLU* Link;
		Timer Time;
		int Threshold;
		char Data;
	};

	enum EState
	{
		Excited,
		Inhibited
	};

	EState Proceed( void );
	EState GetState( void );
	EState GetState( int& ExcitementValue );

	EState ConnectTo ( OutConnection Link );
	EState DisconnectFrom ( InConnection Link );

	void Input( char* Data,int Length );
	EState Output( char*& Data,int& Length);

private:
	const int MaxInput;
	vector<InConnection> InPool;
	const int MaxOutput;
	vector<OutConnection> OutPool;

	vector<TLU*> Neighbors;

	int Excitement;
	EState State;

	void Inhibite ( void );
	void CalculateActivation ( OutConnection& Link );
	void SendActivation ( OutConnection Link );
};

#endif